package ch.uzh.ifi.seal.ssqa.popup.actions;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IActionDelegate;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;

import ch.uzh.ifi.seal.ssqa.importer.issuetracking.ClearQuestImporter;

public class ImportIssueTrackingModelAction implements IObjectActionDelegate {
	
	
	Shell shell;
	/**
	 * Constructor for Action1.
	 */
	public ImportIssueTrackingModelAction() {
		super();
	}

	/**
	 * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
	 */
	public void setActivePart(IAction action, IWorkbenchPart targetPart) {
		this.shell = targetPart.getSite().getShell();
	}

	/**
	 * @see IActionDelegate#run(IAction)
	 */
	public void run(IAction action) {
		
		//This is also dependant on a installed ClearTool and access to the VOB data
		new ClearQuestImporter().persistData();
		
		MessageDialog.open(MessageDialog.INFORMATION, this.shell, "Model Loaded", "The Model has been loaded successfully.", SWT.None);
	}

	/**
	 * @see IActionDelegate#selectionChanged(IAction, ISelection)
	 */
	public void selectionChanged(IAction action, ISelection selection) {
	}

}
